//
//  MyCollectionExerciseViewController.m
//  Founder_study
//
//  Created by hongbao.cui on 14-8-21.
//  Copyright (c) 2014年 com.founder. All rights reserved.
//

#import "MyCollectionExerciseViewController.h"
#import "Sqlite.h"
#import "SwipeView.h"
#import "FMNavgationItem.h"
#import "ApplicationUtils.h"
@interface MyCollectionExerciseViewController ()

@end

@implementation MyCollectionExerciseViewController
@synthesize inforDict;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}
-(void)initData{
    NSString *paperTitleAndCount = [NSString stringWithFormat:@"%@ 共01/0%@题",[inforDict objectForKey:@"paper_title"],[inforDict objectForKey:@"count"]];
    CGSize size = [paperTitleAndCount sizeWithFont:[UIFont systemFontOfSize:13.0] constrainedToSize:CGSizeMake(FMSCREENWIDTH-80, 35) lineBreakMode:NSLineBreakByWordWrapping];
    [titleLabel setText:paperTitleAndCount];
    [titleLabel setFrame:CGRectMake(10, (MAX(titleLabel.frame.size.height, 30)-size.height)/2, size.width, size.height)];
    [headerBg setFrame:CGRectMake(0, 0, FMSCREENWIDTH, MAX(titleLabel.frame.size.height, 30))];
    NSMutableArray *array = [Sqlite selectCollectionQuestionPaper_Id:[inforDict objectForKey:@"paper_id"]];
    if (!self.paperArray) {
        self.paperArray = [NSMutableArray arrayWithCapacity:1];
    }
    [self.paperArray addObjectsFromArray:array];
    
    NSDictionary *dataDict = [self.paperArray objectAtIndex:0];//更新第一题收藏按钮
    //更新收藏按钮
    NSString *favourite_flag = [NSString stringWithFormat:@"%@",[dataDict objectForKey:@"favourite_flag"]];
    BOOL isCollection = NO;
    if ([favourite_flag isEqualToString:@"1"]) {
        isCollection = YES;
    }
    [collectionBtn setSelected:isCollection];
    [self.swipeView reloadData];
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self initData];
    self.navigationItem.title = @"我的收藏";
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(void)dealloc{
    self.inforDict = nil;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
